package com.sparkseries.common.swagger;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 创建Swagger配置类
 */
@Configuration
public class SwaggerConfig {

    @Bean
    public GroupedOpenApi commonAPI() {
        return GroupedOpenApi.builder().group("default")
                .pathsToMatch("/**")
                .packagesToScan("com.sparkseries").build();
    }

    @Bean
    public OpenAPI customOpenAPI() {
        Contact contact = new Contact();
        contact.setName("sparkseries开源组");
        contact.setUrl("https://www.bilibili.com/video/BV1GJ411x7h7/?spm_id_from=333.337.search-card.all.click&vd_source=07c0898945a6c8a01a95168830d65f1d");
        contact.setEmail("2775640861@qq.com");

        return new OpenAPI().components(new Components()).info(new Info()
                        .title("sparkseries-cloud开源组")
                        .description("落魄谷中寒风吹,春秋蝉鸣少年归")
                        .contact(contact)
                        .version("1.0.0")
                        .termsOfService("https://www.bilibili.com/video/BV1GJ411x7h7/?spm_id_from=333.337.search-card.all.click&vd_source=07c0898945a6c8a01a95168830d65f1d")
                        .license(new License().name("Apache 2.0")
                                .url("https://www.bilibili.com/video/BV1GJ411x7h7/?spm_id_from=333.337.search-card.all.click&vd_source=07c0898945a6c8a01a95168830d65f1d")));
    }
}
